from appium import webdriver
from appium.webdriver.common.appiumby import By
from time import sleep
from map_zoom import *

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7'
desired_caps['deviceName'] = '127.0.0.1:62001'
desired_caps['app'] = r'D:\android\apk\gaode.apk'
desired_caps['appPackage'] = 'com.autonavi.minimap'
desired_caps['appActivity'] = 'com.autonavi.map.activity.SplashActivity'
desired_caps['noReset'] = False

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
driver.implicitly_wait(10)
sleep(3)

# 点击 同意权限
driver.find_element(By.ID, 'com.autonavi.minimap:id/agree').click()
# 点击 进入地图
driver.find_element(By.ID, 'com.autonavi.minimap:id/enter_amap').click()
# 点击 允许1
driver.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button').click()
# 点击 允许2
driver.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button').click()
# 点击 允许3
driver.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button').click()
# 点击 任意位置
driver.find_element(By.ID, 'com.autonavi.minimap:id/map_widget_container').click()

smaller(driver)
sleep(5)

bigger(driver)
sleep(5)

driver.quit()